package com.example.yuejian.Model;

import com.example.yuejian.RetrofitListener;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by 释怀 on 2018/9/27.
 */

public class RetrofitBaseModel {


   public <T> void bindCallback(Call<T> call, final RetrofitListener<T> listener, final int flag) {
        Callback<T> callback=new Callback<T>() {
            @Override
            public void onResponse(Call<T> call, Response<T> response) {
                listener.onSuccess(response.body(),flag);
            }

            @Override
            public void onFailure(Call<T> call, Throwable t) {
                listener.onFail();
            }
        };
        call.enqueue(callback);
    }
}
